package com.AdvancedDemos.Learn网络编程.CS架构.useTCP5改进4实现服务器收到信息时反馈给所有客户端;

import java.io.DataInputStream;
import java.io.InputStream;
import java.net.Socket;

public class ClientReceiveThread extends Thread {

    //定义成员变量，将每个线程对象与每个socket绑定
    private Socket thisSocket;

    public ClientReceiveThread(Socket thisSocket) {
        this.thisSocket = thisSocket;
    }

    @Override
    public void run() {
        try {
            //接收数据
            //获取输入流
            InputStream inputStream = thisSocket.getInputStream();
            DataInputStream dis = new DataInputStream(inputStream);
            while (true) {
                String data = dis.readUTF();
                System.out.println(data);
            }
        } catch (Exception e) {
            System.out.println("出现异常啦");
        }
    }
}
